<template>
  <div>
    <el-row :gutter="50">
      <el-form ref="elForm" :model="formData" size="mini" label-width="200px" label-position="left">
        <div>
          <el-col :span="20">
            <el-form-item label="所有权登记：" prop="field101">
              <el-select v-model="formData.field101" placeholder="请选择" :style="{ width: '100%'}" class="select_left" @change="indexSelect">
                <el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value"
                  :disabled="item.disabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </div>
        <el-col :span="5">
          <el-form-item label="所有权登记必要文件：" prop="field102">
            <el-checkbox-group v-model="formData.field102" size="small">
              <el-checkbox v-for="(item, index) in field102Options" :key="index" :label="item.value"
                :disabled="item.disabled">{{ item.label }}
              </el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-col>
        <el-col :span="24"> 
          <el-row type="flex" justify="start" align="top">
            <el-col :span="9">
              <el-form-item label-width="78px" label="申请人：" prop="field118">
                <el-input v-model="formData.field118" placeholder="请输入姓名" clearable :style="{ width: '100%' }">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="15">
              <el-form-item label-width="170px" label="申请人身份证件号码：" prop="field114">
                <el-input v-model="formData.field114" placeholder="请输入申请人身份证件号码" clearable
                  :style="{ width: '100%' }"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="24">
          <el-row type="flex" justify="start" align="top">
            <el-col :span="3">
              <el-form-item label-width="0" prop="field119">
                <el-radio-group v-model="formData.field119" size="medium">
                  <el-checkbox v-for="(item, index) in field119Options" :key="index" :label="item.value"
                    :disabled="item.disabled">{{ item.label }}</el-checkbox>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item label-width="0" prop="field122">
                <el-input v-model="formData.field122" placeholder="请输入代理人姓名" clearable
                  :style="{ width: '100%' }"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label-width="160px" label="代理人身份证件号码：" prop="field124">
                <el-input v-model="formData.field124" placeholder="请输入代理人身份证件号码" clearable
                  :style="{ width: '100%' }"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="24">
          <el-row type="flex" justify="center" align="top">
            <el-col :span="6">
              <el-form-item label-width="0" prop="field127">
                <el-button type="primary" size="mini" @click="submitForm"> 受理 </el-button>
              </el-form-item>
            </el-col>
            <el-col :span="1">
              <el-form-item label-width="0" prop="field126">
                <el-button type="primary" size="mini" @click="resetForm"> 取消 </el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
export default {
  components: {},
  props: [],
  data() {
    return {
      values:'',
      formData: {
        field101: 1,
        field102: [],
        field118: "",
        field114: "",
        field119: 1,
        field122: '',
        field124: '',
        field127: '',
        field126: '',
      },
      field101Options: [{
        "label": "异议登记",
        "value": 1
      }, {
        "label": "异议注销",
        "value": 2
      }],
      field102Options: [{
        "label": "（一）申请人签名或盖章的登记申请书；",
        "value": 1
      }, {
        "label": "（二）申请人身份证明；",
        "value": 2
      }],
      field119Options: [{
        "label": "代理人：",
        "value": 1
      }],
      likefiles:{
        precontractStatus:"<已受理>",
        demurTypeId:'',
        businessNum:'',
        createTime:'',
        proposerName:'',
        proposerCard:'',
        assignee:"业务员小王"
      }
    }
  },
  computed: {},
  watch: {},
  created() { },
  mounted() { },
  methods: {
    submitForm() {
      if(this.formData.field102.length!=2){
        this.$message.error("申请资料不齐全，请补齐受理");
      }else if(this.formData.field118==''){
        this.$message.error("请注意，申请人不能为空");
      }else if(this.formData.field114==''){
        this.$message.error("请注意，申请人身份证号不能为空");
      }else{
        this.$confirm('确认受理该业务？', '确认信息', {
          distinguishCancelAndClose: true,
          confirmButtonText: '受理',
          cancelButtonText: '放弃受理'
        })
          .then(() => {
            this.$message({
              type: 'info',
              message: '受理成功'
            });
            this.likefiles.demurTypeId=this.formData.field101;
            this.likefiles.proposerName=this.formData.field118;
            this.likefiles.proposerCard=this.formData.field114;
            let aData = new Date();
            let dateValue = aData.getFullYear() + "-" + (aData.getMonth() + 1) + "-" + aData.getDate()+' '+aData.getHours()+':'+aData.getMinutes()+':'+aData.getSeconds();
            this.likefiles.createTime=dateValue;
            this.likefiles.businessNum= aData.getTime().toString();
            this.$axios.post("/register-serv/demurs/add",this.likefiles).then((res) => {
              this.$router.push('/Datas');
            }); 
          })
          .catch(action => {
            this.$message({
              type: 'info',
              message: action === 'cancel'
                ? '放弃受理'
                : '放弃受理'
            })
          });
      }
    
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
    indexSelect(obj) {
			this.formData.field1012=this.field101Options[obj].label;
      console.log(this.formData.field1012)
		},
    
  }
}

</script>
<style scope>
.select_left{
  margin-left: -425px;
}
.el-input__inner{
  width: 50%;
}
</style>
